import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { RouterIndexComponent } from './router-index.component';
import { RouterDetailComponent } from './router-detail.component';
import { RouterListComponent } from './router-list.component';
import { RouterAnotherComponent } from './router-another.component';
import { RouterDefaultComponent } from './router-default.component';

import { RouterPlayerDetailResolveService } from './router-player-detail-resolve.service';
import { CanDeactivateGuard }    from '../can-deactivate-guard.service';

const routes: Routes = [
    {
        path: '',
        redirectTo: 'index',
        pathMatch: 'full'
    },
    {
        path: 'index', component: RouterIndexComponent,
        children: [
            {
                path: '', component: RouterListComponent, children: [
                    {
                        path: 'detail/:id', component: RouterDetailComponent,
                        canDeactivate: [CanDeactivateGuard],
                        resolve: {
                            player: RouterPlayerDetailResolveService
                        }
                    },
                    { path: '', component: RouterDefaultComponent }
                ]
            },
            { path: 'another', component: RouterAnotherComponent }
        ]
    }
];

@NgModule({
    imports: [RouterModule.forChild(routes)],
    exports: [RouterModule],
})
export class RouterRoutingModule { }

export const routedComponents = [
    RouterIndexComponent,
    RouterDetailComponent,
    RouterListComponent,
    RouterAnotherComponent,
    RouterDefaultComponent
];